--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Commit 8ad8dc882547594c759d016213efa40f07465c33
Parents : 25d7b96
Author : Ivan <ivan@quad4.io>
Signature : Signature validation error
Date : 2026-04-23T03:16:46-05:00
feat(tests): update Argos CLI integration tests with network checks for Stanza resource fetching
Changes
1 files changed, 46 insertions(+), 1 deletions(-)
Diff
diff --git a/tests/backend/test_translator_argos_integration.py b/tests/backend/test_translator_argos_integration.py
index 5f2daab4..a4307f7a 100644
--- a/tests/backend/test_translator_argos_integration.py
+++ b/tests/backend/test_translator_argos_integration.py
@@ -3,6 +3,8 @@
"""Optional integration checks for Argos CLI (skipped when not installed)."""
import shutil
+import urllib.error
+import urllib.request
import pytest
@@ -17,6 +19,29 @@ def _argos_cli_on_path() -> bool:
return _find_argos_cli_executable() is not None
+_STANZA_RESOURCES_URL = (
+ "https://raw.githubusercontent.com/stanfordnlp/stanza-resources/"
+ "main/resources_1.10.0.json"
+)
+
+
+def _argos_cli_needs_network() -> bool:
+ """Argos sentence splitting can trigger Stanza to fetch resources over HTTPS."""
+ req = urllib.request.Request(
+ _STANZA_RESOURCES_URL,
+ method="HEAD",
+ headers={"User-Agent": "MeshChatX-Tests/1"},
+ )
+ try:
+ with urllib.request.urlopen(req, timeout=5) as resp:
+ code = getattr(resp, "status", resp.getcode())
+ return code is not None and int(code) < 500
+ except urllib.error.HTTPError as e:
+ return e.code < 500
+ except OSError:
+ return False
+
+
@pytest.mark.integration
def test_find_argos_cli_matches_shutil_which():
expected = None
@@ -29,12 +54,32 @@ def test_find_argos_cli_matches_shutil_which():
@pytest.mark.integration
@pytest.mark.skipif(not _argos_cli_on_path(), reason="Argos CLI not on PATH")
+@pytest.mark.skipif(
+ not _argos_cli_needs_network(),
+ reason="Network unreachable (Argos CLI may download Stanza resources)",
+)
def test_translate_en_es_via_cli_round_trip():
handler = TranslatorHandler(enabled=True)
assert handler.has_argos_cli
assert not handler.has_argos_lib
- result = handler.translate_text("Hello", "en", "es", use_argos=True)
+ try:
+ result = handler.translate_text("Hello", "en", "es", use_argos=True)
+ except RuntimeError as exc:
+ err = str(exc)
+ if any(
+ needle in err
+ for needle in (
+ "Network is unreachable",
+ "Failed to establish a new connection",
+ "Max retries exceeded",
+ )
+ ):
+ pytest.skip(
+ "Argos CLI could not reach Stanza resources over HTTPS "
+ "(offline, sandbox, or subprocess has no route)"
+ )
+ raise
assert result["source"] == "argos"
assert result["source_lang"] == "en"
assert result["target_lang"] == "es"
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────